﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework;

namespace Batalha_Estelar
{
    class Missel : GameObject
    {
   
        #region Fields

        protected float Velocidade;

        #endregion 

        #region Construtores

        public Missel(Game game, Vector2 posicao, Vector2 direcaoMissel)
            : base(game)
        {
            Textura = game.Content.Load<Texture2D>(@"Imagens/missel");
            Posicao = posicao;
            Direcao = direcaoMissel;
            Velocidade = 700.0f;
        }

        #endregion

        #region GameObject Methods

        public override void Update(GameTime gameTime)
        {
            var gameSpeed = GameConfig.GetCurrent().GameSpeed;
            var elapsedGameTime = (float)gameTime.ElapsedGameTime.TotalSeconds;
            var controla = new ControleTela();

            Posicao += Direcao * Velocidade * gameSpeed * elapsedGameTime;
        }

        public override void Draw(SpriteBatch spriteBatch)
        {
            spriteBatch.Draw(Textura, Posicao, Color.White);
        }

        protected override void Dispose(bool disposing)
        {
            //nada por enquanto...
            return;
        }

        #endregion

        #region Missel Methods

        public virtual bool CanDestroy()
        {
            var controlaTela = new ControleTela();

            var width = Textura.Bounds.Width;
            var height= Textura.Bounds.Height;

            return !controlaTela.EstaDentro(this.Posicao, width, height);
        }

        #endregion

    }
}
